# https://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false
from urllib import request,parse

url = "https://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false"
data ={
    "first": "true",
    "pn": 1,
    "kd": "测试工程师"
}
# 设置请求头字典
headers= {'user-agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) '
                       'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 '
                       'Mobile Safari/537.36',
          'referer':'https://www.lagou.com/jobs/list_python/p-city_0?&cl=false&fromSearch=true&labelWords=&suginput='}
# 设置请求参数,请求方式,请求头  同时把请求参数转换为byte数组
req = request.Request(url,parse.urlencode(data).encode(),headers=headers,method="POST")
# 发起请求
resp = request.urlopen(req)
# 获取响应值
print(resp.read().decode("utf-8"))
